package org.example.everyday;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/5/5 0005 12:25
 */
public class Lc713 {
    public static void main(String[] args) {
        Lc713 lc713 = new Lc713();
        int[] nums = {1,2,3};
        lc713.numSubarrayProductLessThanK(nums,0);
    }

    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int n = nums.length;
        int res = 0;
        int prod = 1,i = 0;
        for(int j = 0; j < n; j++){
            prod *= nums[j];
            while(i <= j && prod >= k){
                prod /= nums[i];
                i++;
            }
            res += j - i + 1;
        }
        return res;
    }

}
